package com.cuiweiyou.phpjavaencrypt;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {

	private EditText mClearText, mCipherText, mCipherText2;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		mClearText = (EditText) findViewById(R.id.et_clear);
		mCipherText = (EditText) findViewById(R.id.et_cipher);
		mCipherText2 = (EditText) findViewById(R.id.et_dencrypt);

		// 加密
		findViewById(R.id.doEncrypt).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				mCipherText.setText(DESUtil.encrypt(mClearText.getText().toString()));
			}
		});

		// 解密
		findViewById(R.id.doDencrypt).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				mCipherText2.setText(DESUtil.decrypt(mCipherText.getText().toString()));
			}
		});
	}
}
